home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch1 / RubrLine.frm (.txt) < prev    next >
Visual Basic Form  |  1999-03-19  |  2KB  |  64 lines

  1. VERSION 5.00
  2. Begin VB.Form frmRubrLine 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "RubrLine"
  5.    ClientHeight    =   4140
  6.    ClientLeft      =   1140
  7.    ClientTop       =   1515
  8.    ClientWidth     =   6690
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   4140
  12.    ScaleWidth      =   6690
  13. Attribute VB_Name = "frmRubrLine"
  14. Attribute VB_GlobalNameSpace = False
  15. Attribute VB_Creatable = False
  16. Attribute VB_PredeclaredId = True
  17. Attribute VB_Exposed = False
  18. Option Explicit
  19. Private Rubberbanding As Boolean
  20. Private OldMode As Integer
  21. Private FirstX As Single
  22. Private FirstY As Single
  23. Private LastX As Single
  24. Private LastY As Single
  25. ' Start rubberbanding.
  26. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  27.     ' Let MouseMove know we are rubberbanding.
  28.     Rubberbanding = True
  29.     ' Save DrawMode so we can restore it later.
  30.     OldMode = DrawMode
  31.     DrawMode = vbInvert
  32.     ' Save the starting coordinates.
  33.     FirstX = X
  34.     FirstY = Y
  35.     ' Draw the initial rubberband line.
  36.     LastX = X
  37.     LastY = Y
  38.     Line (FirstX, FirstY)-(LastX, LastY)
  39. End Sub
  40. ' Continue rubberbanding.
  41. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  42.     ' If we are not rubberbanding, do nothing.
  43.     If Not Rubberbanding Then Exit Sub
  44.     ' Erase the previous rubberband line.
  45.     Line (FirstX, FirstY)-(LastX, LastY)
  46.     ' Draw the new rubberband line.
  47.     LastX = X
  48.     LastY = Y
  49.     Line (FirstX, FirstY)-(LastX, LastY)
  50. End Sub
  51. ' Stop rubberbanding.
  52. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  53.     ' If we are not rubberbanding, do nothing.
  54.     If Not Rubberbanding Then Exit Sub
  55.     ' We are no longer rubberbanding.
  56.     Rubberbanding = False
  57.     ' Erase the previous rubberband line.
  58.     Line (FirstX, FirstY)-(LastX, LastY)
  59.     ' Restore the original DrawMode.
  60.     DrawMode = OldMode
  61.     ' Make the final line permanent.
  62.     Line (FirstX, FirstY)-(LastX, LastY)
  63. End Sub
  64.